<script setup lang="jsx">
import { ref } from 'vue'
import BaseModel from '@/components/Model/index.vue'
import ConfigForm from '@/components/CRUD/ConfigForm.vue'

import { addLawsuitServer } from '@/api/lawsuit'


const model = defineModel({ type: Boolean })



const props = defineProps({
  row: {
    type: Object,
  },
})

const id = ref(props.row?.arrears_data_id)

// 下拉选项
const courtOptions = [
  { label: '北京市朝阳区中级人民法院', value: 'bj_cy' },
  { label: '北京市海淀区人民法院', value: 'bj_hd' }
]
const levelOptions = [
  { label: '一审', value: '1' },
  { label: '二审', value: '2' }
]
const lawyerOptions = [
  { label: '请选择出庭律师', value: '' },
  { label: '张三', value: 'zhangsan' },
  { label: '李四', value: 'lisi' }
]

// 表单配置
const createForm = [
  { label: '法院', key: 'court_number', type: 'select', required: true, props: { placeholder: '请选择法院' }, options: courtOptions },
  { label: '法庭', key: 'court_id', type: 'input', required: true, props: { placeholder: '请输入' } },
  { label: '审级', key: 'level', type: 'select', required: true, props: { placeholder: '请选择审级' }, options: levelOptions },
  { label: '开庭时间', key: 'open_datetime', type: 'datepicker', required: true, props: { placeholder: '请选择日期', valueFormat: 'YYYY-MM-DD' } },
  { label: '出庭律师', key: 'open_court_user_id', type: 'select', required: true, props: { placeholder: '请选择出庭律师' }, options: lawyerOptions }
]


function beforeSubmit(data) {
  return {
    ...data,
    arrears_data_id: id.value
  }
}


function haneldClose() {
  model.value = false
}

</script>
<template>
  <BaseModel title="添加开庭信息" v-model="model" v-bind="$attrs" show-close show-submit>
    <ConfigForm :configs="createForm" @close="haneldClose" @beforeSubmit="beforeSubmit" :server="addLawsuitServer" />
  </BaseModel>
</template>

<style lang="scss" scoped></style>